package com.anli.dao;

import com.anli.entity.StockInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/8/30  11:57
 * 描述:
 */
@Mapper
@Repository
public interface TestLockMapper {

    @Select("select stock,goods_id as goodsId,stock_id as stockId,version from base_stock where goods_id=#{goodsId} and stock_id=#{stockId}")
    public StockInfo getStockInfo(StockInfo stockInfo);

    @Update("update base_stock set stock=#{stock} where goods_id=#{goodsId} and stock_id=#{stockId} ")
    public int updateStock(StockInfo stockInfo);


    @Update("update base_stock set stock=#{stock},version=version+1 where goods_id=#{goodsId} and stock_id=#{stockId} and version=#{version} ")
    public int updateStock2(StockInfo stockInfo);

}
